package com.qingdai.service.impl;

import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.qingdai.emuns.*;
import com.qingdai.mapper.CommodityEsMapper;
import com.qingdai.mapper.CommodityMapper;
import com.qingdai.service.CommodityService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 订单 服务实现类
 * </p>
 *
 * @author LiuZiMing
 * @since 2024-01-26
 */
@Service
public class CommodityServiceImpl extends ServiceImpl<CommodityMapper, Commodity> implements CommodityService {
    @Resource
    private CommodityMapper commodityMapper;
    @Resource
    private CommodityEsMapper commodityEsMapper;

    @Override
    public List<CommodityDTO> getCommodityDTOByShopId(Integer shopId) {
        MPJLambdaWrapper<Commodity> wrapper = new MPJLambdaWrapper<>();
        wrapper.eq("t.shop_id", shopId)
                .selectAll(Commodity.class)
                .selectAs(Shop::getName, CommodityDTO::getShopName)
                .leftJoin(Shop.class, Shop::getId, Commodity::getShopId);
        return commodityMapper.selectJoinList(CommodityDTO.class, wrapper);
    }


}
